package org.jeecg.modules.kuner.useruimestatement.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.modules.kuner.useruimestatement.entity.KrUserTimeStatement;
import org.jeecg.modules.kuner.useruimestatement.service.IKrUserTimeStatementService;
import org.jeecg.modules.putil.LoginUserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 用户次数流水记录
 * @Author: jeecg-boot
 * @Date: 2025-02-19
 * @Version: V1.0
 */
@Api(tags = "api-用户次数流水记录")
@RestController
@RequestMapping("/api/krUserTimeStatement")
@Slf4j
public class KrUserTimeStatementApiController extends JeecgController<KrUserTimeStatement, IKrUserTimeStatementService> {
    @Resource
    private IKrUserTimeStatementService krUserTimeStatementService;
    @Resource
    private LoginUserUtil loginUserUtil;

    /**
     * 我的剩余次数
     *
     * @return 查询到的我的剩余次数
     */
    @ApiOperation("会员到期时间")
    @GetMapping("/myTimes")
    public Result<Date> myTimes() {
        Date userTime = krUserTimeStatementService.getUserTime(loginUserUtil.getLoginUser().getId());
        return Result.OK("查询成功！", userTime);
    }

}
